Ubuntu 16.04
Sponsored Link

Manage Volume Groups
2016/09/12
 
This is the basic operation of managing Volume Groups.
It needs to create Phisical Volume first.
[1] Create Volume Group.
root@dlp:~#
vgcreate vg_dlp /dev/sdb1

  Volume group "vg_dlp" successfully created
# specify like follows if you'd like to use multiple devices

root@dlp:~#
vgcreate vg_dlp /dev/sdb1 /dev/sdd1

  Volume group "vg_dlp" successfully created
[2] Display Volume Groups.
root@dlp:~#
vgdisplay vg_dlp

  --- Volume group ---
  VG Name               vg_dlp
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               80.00 GiB
  PE Size               4.00 MiB
  Total PE              20479
  Alloc PE / Size       0 / 0
  Free  PE / Size       20479 / 80.00 GiB
  VG UUID               Q3c0yC-ZgGf-E0aX-tZsv-wLe8-DETH-XDqPER
[3] Change Volume Group's name.
root@dlp:~#
vgrename vg_dlp vg_data

  Volume group "vg_dlp" successfully renamed to "vg_data"
root@dlp:~#
vgdisplay vg_data

  --- Volume group ---
  VG Name               vg_data
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               80.00 GiB
  PE Size               4.00 MiB
  Total PE              20479
  Alloc PE / Size       0 / 0
  Free  PE / Size       20479 / 80.00 GiB
  VG UUID               Q3c0yC-ZgGf-E0aX-tZsv-wLe8-DETH-XDqPER
[4] Display reports of Volume Groups.
root@dlp:~#
vgs

  VG      #PV #LV #SN Attr   VSize  VFree
  centos    1   2   0 wz--n- 49.51g     0
  vg_data   1   0   0 wz--n- 80.00g 80.00g
[5] Scan Volume Groups.
root@dlp:~#
vgscan

  Reading all physical volumes.  This may take a while...
  Found volume group "centos" using metadata type lvm2
  Found volume group "vg_data" using metadata type lvm2
[6] Extend Volume Group.
# add sdc1 to vg_data

root@dlp:~#
vgextend vg_data /dev/sdc1

  Volume group "vg_data" successfully extended
root@dlp:~#
vgdisplay vg_data

  --- Volume group ---
  VG Name               vg_data
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               160.00 GiB
  PE Size               4.00 MiB
  Total PE              20479
  Alloc PE / Size       0 / 0
  Free  PE / Size       20479 / 160.00 GiB
  VG UUID               Q3c0yC-ZgGf-E0aX-tZsv-wLe8-DETH-XDqPER
[7] Reduce Volume Group.
# remove sdc1 from vg_data

root@dlp:~#
vgreduce vg_data /dev/sdc1

  Removed "/dev/sdd1" from volume group "vg_data"
root@dlp:~#
vgdisplay vg_data

  --- Volume group ---
  VG Name               vg_data
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               80.00 GiB
  PE Size               4.00 MiB
  Total PE              20479
  Alloc PE / Size       0 / 0
  Free  PE / Size       20479 / 80.00 GiB
  VG UUID               Q3c0yC-ZgGf-E0aX-tZsv-wLe8-DETH-XDqPER
[8] Delete Volume Group.
# disable target volume group first and delete it

root@dlp:~#
vgchange -a n vg_data

  0 logical volume(s) in volume group "vg_data" now active
root@dlp:~#
vgremove vg_data

  Volume group "vg_data" successfully removed
 
Tweet